// effect_explosion

local effect_explosion = Assault.Entities:New("effect_explosion")

// Derive from entity

effect_explosion:DeriveFromEntity("effect_base")

// On entity created

function effect_explosion:OnEntitySpawn()
	local Size = self:EntityGetMaxLength() / 12
	local Position = self:EntityGetPosition()
	
	// X and Y
	
	local X = Position.X
	local Y = Position.Y
	
	// Sparks
	
	for I = 1, 4 do
		Assault.Entities.EntitiesQuickCreate("effect_sparks", Assault.Vector:New(X + math.random(-(Size * I), Size * I), Y + math.random(-(Size * I), Size * I)), false, false, Color(255, 215, 0, 255), {Width = Size})
		Assault.Entities.EntitiesQuickCreate("effect_sparks", Assault.Vector:New(X + math.random(-(Size * I), Size * I), Y + math.random(-(Size * I), Size * I)), false, false, Color(255, 50, 50, 255), {Width = Size})
		Assault.Entities.EntitiesQuickCreate("effect_sparks", Assault.Vector:New(X + math.random(-(Size * I), Size * I), Y + math.random(-(Size * I), Size * I)), false, false, Color(255, 128, 64, 255), {Width = Size})
	end
	
	// Entity emit sound
	
	self:EntityEmitSound("ambient/explosions/explode_1.wav", Assault.Level.Player)
	
	// Entity remove
	
	self:EntityRemove()
end

// Create

effect_explosion:Create()